package com.asdf.tests;

import static org.junit.Assert.assertEquals;

import java.util.List;

import org.junit.Test;

import com.asdf.application.NetServiceSimulator;
import com.asdf.db.DataBase;
import com.asdf.db.DataBase.DataSource;
import com.asdf.entities.Airport;

public class XMLLoadTest extends AirportTest
{
	@SuppressWarnings({ "unchecked" })
	@Test
	public void AirportsLoad()
	{
		NetServiceSimulator simulator = new NetServiceSimulator( );
		Airport airport = null;
		List<Airport> list = null;
		
		simulator.loadAirports( "airports.xml");
		list = (List<Airport>)DataBase.getInstance( ).getDataSource( DataSource.AirportList);
		
		for (int i = 0; i < arr.length; ++i)
		{
			airport = list.get(i);
			assertEquals("xmlAirport[" + i + "][id]", arr[i][0], airport.getId());
			assertEquals("xmlAirport[" + i + "][name]", arr[i][1], airport.getName());
			assertEquals("xmlAirport[" + i + "][country]", arr[i][2], airport.getCountry());
			assertEquals("xmlAirport[" + i + "][rate]", Double.parseDouble(arr[i][3]), airport.getRate());
			assertEquals("xmlAirport[" + i + "][license]", arr[i][4], airport.getLicenseFile());
		}
	}
}
